home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / timing2.zip / TIMETEST.BAS < prev   
BASIC Source File  |  1989-09-12  |  2KB  |  55 lines

  1. 'TIMETEST.BAS
  2. '----------------------------------------------------------------------------
  3. ' This program does nothing more than demonstrate the two timing
  4. ' SubPrograms, DELAY & BGDELAY
  5. '----------------------------------------------------------------------------
  6. DECLARE SUB DELAY (hun.scnds!)
  7. DECLARE SUB BGDELAY (hun.scnds!, HUN.SCNDS.TO.GO!, status%)
  8.  
  9. '/--------------------------------------------------------------------------/
  10. ' First, the simpler DELAY.  This SubProgram is CALLed with one
  11. ' SINGLE PRECISION (*!*) argument and retains control until that
  12. ' many hundredths of seconds pass.
  13. '/--------------------------------------------------------------------------/
  14. COLOR 14: PRINT "First test: `hard' delay"
  15. COLOR 7: PRINT "   how many hundredths of seconds? :";
  16. LOCATE , , 1: LINE INPUT tmp$
  17. PRINT "   Starting time: "; TIME$
  18. time.to.wait! = VAL(tmp$)             'wait for 5 seconds
  19. CALL DELAY(time.to.wait!)
  20. PRINT "   Ending time  : "; TIME$
  21.  
  22.  
  23. '/--------------------------------------------------------------------------/
  24. ' Second, BGDELAY.  This SubProgram is CALLed with two SINGLE PRECISION (*!*)
  25. ' arguments, and one integer argument: the first S.P. argument tells
  26. ' BGDELAY how many hundredths of seconds are to be delayed; the second
  27. ' S.P. argument is for BGDELAY to tell you how many hundredths of
  28. ' seconds remain until the timeout has occurred.  The third argument, the
  29. ' integer, tells you whether or not the timing is continuing.  Once the
  30. ' third argument falls to 0, the timing is done (ie, a timeout has
  31. ' occurred) less than or equal to 0, then the timeout has occurred!
  32. '/--------------------------------------------------------------------------/
  33. PRINT
  34. COLOR 14: PRINT "Next test: `background' delay"
  35. COLOR 7: PRINT "   how many hundredths of seconds? :";
  36. LOCATE , , 1: LINE INPUT tmp$
  37. PRINT "   Starting time: "; TIME$
  38. time.to.wait! = VAL(tmp$)             'wait for 5 seconds
  39.  
  40. DO
  41.         GOSUB mything                   'go do your thing while waiting
  42.         CALL BGDELAY(time.to.wait!, time.to.go!, st%)
  43. LOOP UNTIL st% = 0
  44.  
  45. PRINT
  46. PRINT "   Ending time  : "; TIME$
  47. END
  48.  
  49. mything:
  50. '---- Do anything you want here, but DON'T change the value of ST% !!
  51. LOCATE CSRLIN, 1
  52. PRINT "   Current time : "; TIME$, , "1/100 seconds left:"; FIX(time.to.go!);
  53. RETURN
  54.  
  55.